package com.geekstudy.week6;

import com.geekstudy.week6.tool.JdbcTool;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class Week6Work9 {

    public static void main(String[] args) {

        try {
            String jdbcUrl = "jdbc:mysql://127.0.0.1:3306/geek_java4";
            String jdbcUsername = "java4";
            String jdbcPassword = "java4";
            Connection connection = DriverManager.getConnection(jdbcUrl, jdbcUsername, jdbcPassword);

            Statement statement = connection.createStatement();
            JdbcTool jdbcTool = new JdbcTool();

            int totalSize = 10000 * 1;
            String tableName = "week6_9m";
            String engine = "MEMORY";
            jdbcTool.createTable(tableName, statement, engine);
            long startTime = System.currentTimeMillis();
            for(int size = 1; size <= totalSize; size++) {
                String insertSql = "insert into " + tableName
                        + " (id, name, remark) values('" + size + "', 'Name" + size + "', 'Remark" + size +"')" ;
                statement.execute(insertSql);
            }
            long finishTime = System.currentTimeMillis();
            long usedTime = finishTime - startTime;
            long usedSecond = usedTime / 1000;
            long usedMinute = usedTime / 60000;
            System.out.println(" record:" + totalSize + "  usedTime:" + usedTime + "  usedSecond:" + usedSecond + " usedMinute:" + usedMinute);


        } catch(Exception e) {
            e.printStackTrace();
        }




    }
}
